import com.itheima.config.SpringConfig;
import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class App {
    public static void main(String[] args) {
        ApplicationContext ctx=new AnnotationConfigApplicationContext(SpringConfig.class);
//        AccountService accountService = (AccountService) ctx.getBean("accountService");
        AccountService accountService = ctx.getBean(AccountService.class);

/*
        Account account = new Account();
        account.setName("Tom123");
        account.setMoney(123456.78);

        accountService.save(account);

        Account ac = accountService.findById(2);
        System.out.println(ac);
*/

        List<Account> all = accountService.findAll();
        for (Account account : all) {
            System.out.println(account);
        }
    }
}
